package com.xpec.c4.service.module;

/*
import static org.junit.Assert.*;

import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;

import org.junit.Test;
*/

public class RecordedQueueTest {
/*
	@Test
	public void testSize() {
		
		RecordedQueue<Object> queue = new RecordedQueue<Object>(new ConcurrentLinkedQueue<Object>());
		
		queue.add(new String(""));
		queue.add(new String(""));
		
		assertEquals(queue.size(),2);
		
		queue.poll();
		assertEquals(queue.size(),1);
		
		queue.add(new Integer(1));
		assertEquals(queue.size(),2);		
	}

	@Test
	public void testGetCountingMap() {
		
		RecordedQueue<Object> queue = new RecordedQueue<Object>(new ConcurrentLinkedQueue<Object>());	
		queue.add(new String(""));
		queue.add(new String(""));
		queue.add(new String(""));
		
		queue.add(new Integer(1));
		queue.add(new Integer(2));
		queue.add(new Integer(3));
		queue.add(new Integer(4));
		
		queue.add(new Float(1.f));
		queue.add(new Integer(4));
		
		Map<Class,AtomicInteger> map = queue.getCountingMap();
		int v = 0;
		
		v = map.get(String.class).get();
		assertEquals(v,3);
		
		v = map.get(Integer.class).get();
		assertEquals(v,5);		
		
		v = map.get(Float.class).get();
		assertEquals(v,1);	
		
		Iterator<Object> it = queue.iterator();		
		while(it.hasNext())
		{
			Object o = it.next();
			if(o instanceof String)
			{
				it.remove();
			}
		}
		v = map.get(String.class).get();
		assertEquals(v,0);

		it = queue.iterator();		
		while(it.hasNext())
		{
			Object o = it.next();
			if(o instanceof Integer)
			{
				it.remove();
				break;
			}
		}	
		v = map.get(Integer.class).get();
		assertEquals(v,4);			
	}

	@Test
	public void testPeek() {
		RecordedQueue<Object> queue = new RecordedQueue<Object>(new ConcurrentLinkedQueue<Object>());	
		queue.add(new String(""));
		queue.peek();
		
		assertEquals(queue.size(),1);
	}

	@Test
	public void testIterator() {
		RecordedQueue<Object> queue = new RecordedQueue<Object>(new ConcurrentLinkedQueue<Object>());	
		queue.add(new String(""));
		queue.add(new String(""));
		queue.add(new String(""));
		
		Iterator<Object> it = queue.iterator();
		it.remove();
		
		Map<Class,AtomicInteger> map = queue.getCountingMap();
		assertEquals(map.size(),1);
		
		int v = map.get(String.class).get();
		assertEquals(v,2);
		
		while(it.hasNext())
		{
			it.remove();
			it.next();
		}
		v = map.get(String.class).get();
		assertEquals(v,0);
	}
*/
}
